//    Copyright (C) Kherty.  All rights reserved.
using System;

namespace OpenLS.Spreadsheet.Extensibility
{
    public class AllowStringToDateTimeConversionAttribute : ParameterConverterAttribute
    {
        internal override void ConvertImp(ConversionData data)
        {
            if (data.TargetType == typeof(DateTime) && data.Value is string)
            {
                string str = (string)data.Value;
                DateTime dt;
                if (DateTime.TryParse(str, out dt))
                    data.Result = dt;
                else
                    data.Error = Errors.ValueError;
            }
        }
    }
}